home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / SER_PORT.ZIP / SER_PORT.01
Encoding:
Text File  |  1997-01-10  |  7.9 KB  |  232 lines

  1.  
  2. This is the source of the program I received from Stephen Warner
  3. <ee_d316@dcs.kingston.ac.uk>. The program does not work with XTs
  4. (but it does fine with real computers).
  5.  
  6.  
  7. A very simple Serial -> Keyboard Redirector
  8. = ==== ====== ======    ======== ==========
  9.  
  10. ;   Uses Num Pad Keys on another PC. And converts to the correct scan code
  11. ;   that is then sent to the Keyboard Buffer. (COM1 or COM2)
  12. ;
  13. ;   By Stephen Warner. April 1993. (Serial V1.07)
  14. ;
  15. CSEG        SEGMENT PUBLIC 'CODE'
  16.             ASSUME  CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG  ;COM FILE
  17.  
  18.             ORG     0100h                   ; Origin for COM Files
  19.  
  20. Serial7:    JMP     Install                 ; Install TSR
  21.  
  22.  
  23. COM         EQU     03F8h                   ; Select Serial Port
  24.  
  25. CR          EQU     0Dh                     ; Return
  26. LF          EQU     0Ah                     ; LineFeed
  27. EOT         EQU     "$"                     ; End of text
  28. Bell        EQU     07h                     ; Bell
  29. cc          EQU     1Bh                     ; Control Code
  30.  
  31. ASC_Up      EQU     00111000b               ; Defining ASCII Values for keypad
  32. ASC_Down    EQU     00110010b               ; Entry
  33. ASC_Left    EQU     00110100b
  34.  
  35. ASC_UpLeft  EQU     00110111b
  36. ASC_UpRight EQU     00111001b
  37. ASC_DoLeft  EQU     00110001b
  38. ASC_DoRight EQU     00110011b
  39. ASC_Cancel  EQU     00101100b
  40. ASC_Select  EQU     00001010b
  41.  
  42.  
  43. IRQ         EQU     4                       ; IRQ4 for COM1 Interrupts
  44. INT_MASK    EQU     11101111b               ; IRQ4 Mask for 8259
  45.  
  46. DATA        EQU     COM                     ; Serial Ports Data
  47. IER         EQU     COM+1                   ; Interrupt Enable Register
  48. MCR         EQU     COM+4                   ; Modem Control Register
  49. MSR         EQU     COM+6                   ; Modem Control Status
  50.  
  51. PIC_MASK    EQU     21h                     ; 8259 Interrupt Mask Port
  52. PIC_EOI     EQU     20h                     ; 8259 EOI Port
  53.  
  54. Int_0C:     PUSH    AX                      ; Store Registers
  55.             PUSH    BX
  56.             PUSH    CX
  57.             PUSH    DX
  58.             PUSH    SI
  59.             PUSH    DI
  60.             PUSH    DS
  61.             PUSH    ES
  62.             PUSH    BP
  63.  
  64.             MOV     DX,MCR                  ; Read the Modem Control Register
  65.             IN      AL,DX                   ; Or else!!!!
  66.       
  67.             MOV     DX,DATA                 ; Character from Serial Port
  68.             IN      AL,DX 
  69.  
  70.             MOV     DI,0B800h               ; Display Recieved Character
  71.             MOV     DS,DI
  72.             MOV     DI,0
  73.             MOV     DS:[DI],AL
  74.  
  75.  
  76. Up:         CMP     AL,ASC_Up
  77.             JNZ     Down     
  78.             MOV     CH,48h                  ; Output Up to Keyboard Buffer
  79.             JMP     Out1C
  80.  
  81. Down:       CMP     AL,ASC_Down
  82.             JNZ     Left
  83.             MOV     CH,50h                  ; Output Down to Keyboard Buffer
  84.             JMP     Out1C
  85.  
  86. Left:       CMP     AL,ASC_Left
  87.             JNZ     Right
  88.             MOV     CH,4Bh                  ; Output Left to Keyboard Buffer
  89.             JMP     Out1C
  90.  
  91. Right:      CMP     AL,ASC_Right
  92.             JNZ     UpLeft
  93.             MOV     CH,4Dh                  ; Output Right to Keyboard Buffer
  94.             JMP     Out1C
  95.  
  96. UpLeft:     CMP     AL,ASC_UpLeft
  97.             JNZ     UpRight     
  98.             MOV     CH,4Bh                  ; Output Up-Left to Keyboard Buffer
  99.             MOV     AL,48h
  100.             JMP     Out2C
  101.  
  102. UpRight:    CMP     AL,ASC_UpRight
  103.             JNZ     DownLeft
  104.             MOV     CH,4Dh                  ; Output Up-Right to Keyboard Buffer
  105.             MOV     AL,48h
  106.             JMP     Out2C
  107.  
  108. DownLeft:   CMP     AL,ASC_DoLeft
  109.             JNZ     DownRight
  110.             MOV     CH,4Bh                  ; Output Down-Left to Keyboard Buffer
  111.             MOV     AL,50h
  112.             JMP     Out2C
  113.  
  114. DownRight:  CMP     AL,ASC_DoRight
  115.             JNZ     Cancel
  116.             MOV     CH,4Dh                  ; Output Down-Right to Keyboard Buffer
  117.             MOV     AL,50h
  118.             JMP     Out2C
  119.  
  120. Cancel:     CMP     AL,ASC_Cancel
  121.             JNZ     Select
  122.             MOV     CH,1Ch
  123.             MOV     AH,05h
  124.             MOV     CX,011Bh                ; Output Select to Keyboard Buffer
  125.             INT     16h
  126.             JMP     INT_EOJ
  127.  
  128. Select:     CMP     AL,ASC_Select
  129.             JNZ     INT_EOJ
  130.             MOV     CH,1Ch
  131.             MOV     AH,05h
  132.             MOV     CX,1C0Dh                ; Output Return to Keyboard Buffer
  133.             INT     16h
  134.             JMP     INT_EOJ
  135.  
  136. Out2C:      PUSH    CX                      ; Output AL to Keyboard Buffer
  137.             MOV     CH,AL                   ; But store Register CX
  138.             MOV     AH,05h
  139.             MOV     CL,00h
  140.             INT     16h
  141.             POP     CX
  142.      
  143. Out1C:      MOV     AH,05h                  ; Output CH to Keyboard Buffer
  144.             MOV     CL,00h
  145.             INT     16h
  146.  
  147. INT_EOJ:    MOV     AL,20h                  ; Send EOI to 8259
  148.             OUT     PIC_EOI,AL
  149.  
  150.             POP     BP                      ; Restore Registers
  151.             POP     ES
  152.             POP     DS
  153.             POP     DI
  154.             POP     SI
  155.             POP     DX
  156.             POP     CX
  157.             POP     BX
  158.             POP     AX
  159.            
  160.             IRET
  161.  
  162. Install:    MOV     AH,09h                  ; Display Program Info
  163.             MOV     DX,Offset BootMess
  164.             INT     21h
  165.              
  166.             MOV     AX,3500h+IRQ+8          ; Get Interrupt vector
  167.             INT     21h
  168.  
  169.             MOV     DX,Offset int_0C        ; Checks to see if already
  170.             CMP     BX,DX                   ; Installed
  171.             JZ      Already                 ; If so display Installed message
  172.  
  173.             MOV     AX,2500h+IRQ+8          ; Set Interrupt vector
  174.             MOV     DX,Offset int_0C 
  175.             INT     21h
  176.         
  177.             MOV     AX,00h+10000010b        ; Initilise Com Port 1
  178.             MOV     DX,0000h                ; Baud Rate 1200, 7-N-1
  179.             INT     14h
  180.  
  181.             MOV     DX,MCR                  ; Set Modem-Control Register
  182.             MOV     AL,00001011b            ; DTR, RTS and OUT2 bits
  183.             OUT     DX,AL
  184.  
  185.             MOV     DX,IER                  ; Set Interrupt Enable Register
  186.             MOV     AL,00000001b            ; On Serial Port Controller
  187.             OUT     DX,AL
  188.  
  189.             IN      AL,PIC_MASK             ; Read Current 8259 mask
  190.             AND     AL,INT_MASK             ; Set Mask for Com Port not bit 4
  191.             OUT     PIC_MASK,AL             ; Write new 8259 mask
  192.  
  193.             MOV     AH,09h                  ; Display Installed..
  194.             MOV     DX,Offset InstMess
  195.             INT     21h
  196.  
  197.             MOV     DX,Offset Install       ; Terminate Stay Resident (Exit)
  198.             INT     27h
  199.  
  200. Already:    MOV     AH,09h                  ; Display Already Installed..
  201.             MOV     DX,Offset AlreMess
  202.             INT     21h
  203.             RET                             ; Exit without Installing TSR
  204.  
  205. BootMess:   DB      cc,"[2J",cc,"[f",cc,"[44m",cc,"[1;33m",cc,"[1;2H"
  206.             DB      "ZDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?"
  207.             DB      cc,"[2;2H"
  208.             DB      "3                   Stephen Warner TSR v1.07 (c) Apr 1993                   CD?"
  209.             DB      cc,"[3;2H"
  210.             DB      "3            This TSR is used with Group 8's Serial Keypad/Mouse            3 3"
  211.             DB      cc,"[4;2H"
  212.             DB      "@DBDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDY 3"
  213.             DB      cc,"[5;4H"
  214.             DB      "@DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDY"
  215.             DB      cc,"[40m",cc,"[0;37m",cc,eot
  216.  
  217. InstMess:   DB      " ",cc,"[7;1H",cc,"[7;1H"
  218.             DB      "Keypad/Mouse Driver Installed..."
  219.             DB      lf,lf,cr,eot
  220.  
  221. AlreMess:   DB      " ",cc,"[7;1H"
  222.             DB      "Keypad/Mouse Driver Already Installed..."
  223.             DB      lf,lf,cr,Bell,eot
  224.  
  225. CSEG        ends
  226.             end Serial7
  227.  
  228.  
  229.  
  230.  
  231.  
  232.